<?php
class User_category extends CI_Controller
{
    public function __construct(){
        parent::__construct();
        $this->load->model('user_model');
    }
    public function index(){
        $this->template->write_view('content','add_user_category','');
        $this->template->render();
    }
    public function create(){
        $this->form_validation->set_rules(array(array(
                    'field' => 'user_category_name', 
                    'label' => 'user category name', 
                    'rules' => 'trim|required'
                    )));
        if ($this->form_validation->run() == FALSE)	 {        
             $this->template->write_view('content','add_user_category','');
             $this->template->render();
		}else  
        {
            $input_data['user_category_name']=$this->input->post('user_category_name')  ;           
            $input_data['category_description']=$this->input->post('category_description')  ;
                        
            $this->user_model->create_user_category($input_data);
             
             $this->list_user_category();
        } 
    }
    public function list_user_category(){
        
        $this->session->set_userdata('navigation','List User Category');
        $cond['user_category_deleted']=0;
        $data['user_category_list']=$this->user_model->get_user_category($cond)->result();
        
        $data['navigation']= 'List User Category'; 
        $this->template->write_view('navigation','navigation',$data);
        
        $this->template->write_view('content','list_user_category',$data);
        $this->template->render();
        
    }
} 
?>